using UnityEngine;

public class SPR_YSorting : MonoBehaviour
{
	public SpriteRenderer SPR;

	public string AbovePlayer = "High";

	public string BelowPlayer = "Default";

	[Space(10f)]
	[Header("Sort by Y position (basically its like negative y pos * 6 rounded)")]
	public bool AutomaticRealtimeSorting;

	public int YOffset;

	private void Start()
	{
	}

	private void Update()
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if (!AutomaticRealtimeSorting)
		{
			if (((Component)PlayerManager.Instance).transform.position.y > ((Component)this).transform.position.y)
			{
				((Renderer)SPR).sortingLayerName = AbovePlayer;
			}
			else
			{
				((Renderer)SPR).sortingLayerName = BelowPlayer;
			}
		}
		else
		{
			((Renderer)SPR).sortingOrder = Mathf.RoundToInt((0f - ((Component)SPR).transform.position.y) * 6f) + YOffset;
		}
	}
}
